% TEST_ID: LANG-EXPAND-0065
% CATEGORY: language/convert
% 测试各种类型转成 char

function test_to_char
    assert(all(char([48 49; 50 51]) == ['01'; '23'], 'all'));

    A = "Pythagoras";
    assert(all(char([A; A]) == [
        'Pythagoras'
        'Pythagoras'
    ], 'all'));

    % 将整数转换为字符
    A = [77 65 84 76 65 66];
    C = char(A);
    assert(all(C == 'MATLAB'));

    % 将多个数组转换为字符数组
    A1 = [65 66; 67 68];
    A2 = 'abcd';
    C = char(A1,A2);
    assert(all(C == ['AB  '; 'CD  '; 'abcd'], 'all'));

    % 将字符串转换为字符向量
    A = "Pythagoras";
    C = char(A);
    assert(all(A == 'Pythagoras'));

    C = char({'a', 'b', 'c  d'});
    assert(all(C == ['a   '; 'b   '; 'c  d'], 'all'));

    C = char({'a', 'b', '';'', 'c  d', ''});
    assert(all(C == ['a   '; '    '; 'b   '; 'c  d'; '    '; '    '], 'all'));

    a = strings(1, 2, 2);
    a(1, 1, 1) = "abc";
    b = char(a);
    assert(all(size(b) == [1, 3, 2, 2]))

end
